﻿<%@ Page Title="" Language="C#" MasterPageFile="~/presentation/MasterPage.Master"
    AutoEventWireup="true" CodeBehind="PobytForm.aspx.cs" Inherits="ISHotel_ASP.presentation.PobytForm" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div align="left" class="art-blockcontent-body">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <table>
            <tr>
                <td>
                </td>
                <td align="center">
                    <asp:Label ID="LabelNovyPobyt" runat="server" Text="Nový pobyt"></asp:Label>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelIDTaxy" runat="server" Text="Taxa:"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="DropDownListTax" runat="server" Width="140px" DataSourceID="ODS_taxa"
                        DataTextField="nazev_taxy" DataValueField="id_taxy">
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="ODS_taxa" runat="server" SelectMethod="Select" TypeName="ISHotelApp.Database.TaxaTable">
                    </asp:ObjectDataSource>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelPrijezd" runat="server" Text="Příjezd:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBoxPrijezd" runat="server"></asp:TextBox>
                    <asp:CalendarExtender ID="TextBoxPrijezd_CalendarExtender" runat="server" TargetControlID="TextBoxPrijezd"
                        Format="dd.MM.yyyy">
                    </asp:CalendarExtender>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidatorPrijezd" runat="server" ErrorMessage="*"
                        ControlToValidate="TextBoxPrijezd"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="ValidatorPrijezd" runat="server" ErrorMessage="Zadejte datum ve tvaru DD.MM.RRRR"
                        ControlToValidate="TextBoxPrijezd" ValidationExpression="^[0-9]{1,2}.[0-9]{1,2}.[0-9]{4}$"></asp:RegularExpressionValidator>                    
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelOdjezd" runat="server" Text="Odjezd:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBoxOdjezd" runat="server"></asp:TextBox>
                    <asp:CalendarExtender ID="TextBoxOdjezd_CalendarExtender" runat="server" TargetControlID="TextBoxOdjezd"
                        Format="dd.MM.yyyy">
                    </asp:CalendarExtender>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidatorOdjezd" runat="server" ErrorMessage="*"
                        ControlToValidate="TextBoxOdjezd"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidatorOdjezd" runat="server"
                        ErrorMessage="Zadejte datum ve tvaru DD.MM.RRRR" ControlToValidate="TextBoxOdjezd"
                        ValidationExpression="^[0-9]{1,2}.[0-9]{1,2}.[0-9]{4}$"></asp:RegularExpressionValidator>
                    <asp:CompareValidator ID="CompareValidatorDatum" runat="server" ErrorMessage="Datum odjezdu musí být později než datum příjezdu"
                        ControlToCompare="TextBoxPrijezd" ControlToValidate="TextBoxOdjezd" Operator="GreaterThan" Type="Date"></asp:CompareValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelPokoj" runat="server" Text="Pokoj:"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="DropDownListPokoj" runat="server" Width="140px" DataSourceID="ODS_pokoj"
                        DataTextField="Pokojstring" DataValueField="id_pokoje">
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="ODS_pokoj" runat="server" SelectMethod="Select_list" TypeName="ISHotelApp.Database.PokojTable">
                    </asp:ObjectDataSource>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelHost" runat="server" Text="Host:"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="DropDownListHost" runat="server" Width="140px" DataSourceID="ODS_host"
                        DataTextField="Prijmeni" DataValueField="rodne_cislo">
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="ODS_host" runat="server" SelectMethod="Select" TypeName="ISHotelApp.Database.HostTable">
                    </asp:ObjectDataSource>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelStravovani" runat="server" Text="Stravování:"></asp:Label>
                </td>
                <td>
                    <asp:DropDownList ID="DropDownListStravovani" runat="server" Width="140px" DataSourceID="ODS_stravovani"
                        DataTextField="nazev_stravovani" DataValueField="id_stravovani">
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="ODS_stravovani" runat="server" SelectMethod="Select" TypeName="ISHotelApp.Database.StravovaniTable">
                    </asp:ObjectDataSource>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td align="center">
                    <asp:Button ID="ButtonVlozPobyt" runat="server" Text="Vlož" OnClick="ButtonVlozPobyt_Click" />
                </td>
                <td>
                </td>
            </tr>
        </table>
        <asp:ObjectDataSource ID="ODS_ListPobyt" runat="server" SelectMethod="Select" TypeName="ISHotelApp.Database.PobytTable">
        </asp:ObjectDataSource>
        <br />
        <asp:Label ID="LabelErr" runat="server" Visible="True" ForeColor="Red"></asp:Label>
        <br />
        <br />
        <asp:GridView ID="GridViewPobyt" runat="server" AutoGenerateColumns="False" DataSourceID="ODS_Pobyt"
            AllowPaging="True" DataKeyNames="id_pobytu">        
            <Columns>
                <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:ImageButton ID="ImageButtonDel" runat="server" CommandArgument='<%# Eval("id_pobytu") %>'
                            CommandName="DeletePobyt" OnCommand="button_Command" ImageUrl="~/images/delete.jpg"
                            OnClientClick="javascript: return confirm(&apos;Opravdu smazat pobyt, jeho objednavky stravovani a sluzeb?&apos;);" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ShowHeader="False">
                </asp:TemplateField>
                <asp:hyperlinkfield headertext="Číslo pobytu"
            datatextfield="id_pobytu"
            datanavigateurlformatstring="PobytDetail.aspx?id_pobytu={0}"
            datanavigateurlfields="id_pobytu" />
                <asp:BoundField DataField="id_taxy" HeaderText="Číslo taxy" SortExpression="id_taxy"
                    ItemStyle-HorizontalAlign="Center" />
                <asp:BoundField DataField="prijezd" HeaderText="Příjezd" SortExpression="prijezd"
                    DataFormatString="{0:dd.MM.yyyy}" HtmlEncode="False" HtmlEncodeFormatString="False"
                    ItemStyle-HorizontalAlign="Center" />
                <asp:BoundField DataField="odjezd" HeaderText="Odjezd" SortExpression="odjezd" DataFormatString="{0:dd.MM.yyyy}"
                    HtmlEncode="False" HtmlEncodeFormatString="False" ItemStyle-HorizontalAlign="Center" />
                <asp:BoundField DataField="celkova_suma" HeaderText="Celková cena" SortExpression="celkova_suma"
                    ItemStyle-HorizontalAlign="Center" />
                <asp:TemplateField HeaderText="Zaplaceno" SortExpression="zaplaceno" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <%# (Int32.Parse(Eval("zaplaceno").ToString())) != 0 ? "Ano" : "Ne"%></ItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowSelectButton="True" HeaderText="Upravit" SelectImageUrl="../images/pencil.gif"
                    ButtonType="Image" ItemStyle-HorizontalAlign="Center" />
            </Columns>
        </asp:GridView>
        <asp:ObjectDataSource ID="ODS_Pobyt" runat="server" SelectMethod="Select" TypeName="ISHotelApp.Database.PobytTable">
            <DeleteParameters>
                <asp:Parameter Name="id_pobytu" Type="Int32" />
            </DeleteParameters>
        </asp:ObjectDataSource>
        <br />
        <asp:DetailsView ID="PobytDetailsView" runat="server" Height="50px" Width="525px"
            AutoGenerateRows="False" DataSourceID="ODS_PobytDetail" DataKeyNames="id_pobytu">
            <Fields>
                <asp:TemplateField HeaderText="Číslo pobytu" SortExpression="id_pobytu">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("id_pobytu") %>' ReadOnly="True"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("id_pobytu") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Taxa" SortExpression="id_taxy">
                    <EditItemTemplate>
                        <asp:DropDownList ID="DropDownListTaxDetail" runat="server" Width="140px" DataSourceID="ODS_taxaDetail"
                            DataTextField="nazev_taxy" DataValueField="id_taxy" SelectedValue='<%# Bind("id_taxy") %>'>
                        </asp:DropDownList>
                        <asp:ObjectDataSource ID="ODS_taxaDetail" runat="server" SelectMethod="Select" TypeName="ISHotelApp.Database.TaxaTable">
                        </asp:ObjectDataSource>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="LabelTaxaDetail" runat="server" Text='<%# Bind("id_taxy") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Příjezd" SortExpression="prijezd">
                    <ItemTemplate>
                        <asp:Label ID="LabelPrijezd" runat="server" Text='<%# Bind("prijezd", "{0:dd.MM.yyyy}") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBoxPrijezdDetail" runat="server" Text='<%# Bind("prijezd","{0:MM.dd.yyyy}") %>'></asp:TextBox>
                        <asp:CalendarExtender ID="TextBoxPrijezdDetail_CalendarExtender" runat="server" TargetControlID="TextBoxPrijezdDetail"
                            Format="MM.dd.yyyy" Enabled="True">
                        </asp:CalendarExtender>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorPrijezdDetail" runat="server"
                            ErrorMessage="*" ControlToValidate="TextBoxPrijezdDetail" ValidationGroup="Detail"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="ValidatorPrijezdDetail" runat="server" ErrorMessage="Zadejte datum ve tvaru MM.DD.RRRR"
                            ControlToValidate="TextBoxPrijezdDetail" ValidationExpression="^[0-9]{1,2}.[0-9]{1,2}.[0-9]{4}$"
                            ValidationGroup="Detail"></asp:RegularExpressionValidator>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Odjezd" SortExpression="odjezd">
                    <ItemTemplate>
                        <asp:Label ID="LabelOdjezd" runat="server" Text='<%# Bind("odjezd", "{0:dd.MM.yyyy}") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBoxOdjezdDetail" runat="server" Text='<%# Bind("odjezd", "{0:MM.dd.yyyy}") %>'></asp:TextBox>
                        <asp:CalendarExtender ID="TextBoxOdjezdDetail_CalendarExtender" runat="server" TargetControlID="TextBoxOdjezdDetail"
                            Format="MM.dd.yyyy">
                        </asp:CalendarExtender>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorOdjezdDetail" runat="server"
                            ErrorMessage="*" ControlToValidate="TextBoxOdjezdDetail" ValidationGroup="Detail"></asp:RequiredFieldValidator><br />
                        <asp:RegularExpressionValidator ID="ValidatorOdjezdDetail" runat="server" ErrorMessage="Zadejte datum ve tvaru MM.DD.RRRR"
                            ControlToValidate="TextBoxOdjezdDetail" ValidationExpression="^[0-9]{1,2}.[0-9]{1,2}.[0-9]{4}$"
                            ValidationGroup="Detail"></asp:RegularExpressionValidator><br />
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowEditButton="True" CausesValidation="True" ValidationGroup="Detail" />
            </Fields>
        </asp:DetailsView>
        <asp:ObjectDataSource ID="ODS_PobytDetail" runat="server" SelectMethod="Select" UpdateMethod="Update"
            OnUpdated="PobytDetail_OnUpdated" DataObjectTypeName="ISHotelApp.Database.Pobyt"
            TypeName="ISHotelApp.Database.PobytTable">
            <SelectParameters>
                <asp:ControlParameter PropertyName="SelectedValue" Type="int32" Name="id_pobytu"
                    ControlID="GridViewPobyt"></asp:ControlParameter>
            </SelectParameters>
        </asp:ObjectDataSource>
    </div>
</asp:Content>
